<?php

namespace app\api\model;

use think\Model;
use traits\model\SoftDelete;

class Recipes extends Model
{
    use SoftDelete;
    protected $deleteTime = 'deletetime';

    public function images()
    {
        return $this->hasMany(RecipeImages::class, 'recipe_id', 'id');
    }

    public function category()
    {
        return $this->hasOne(RecipeCategories::class, 'id', 'cate_id')->where('is_show', 1);
    }

    public static function getRecipe($date)
    {
        return self::with(['images', 'category'])->where('date', $date)->select();
    }
}
